/* 2009-2022 VieCode @license VieCode Commercial License @package com.viecode.marketplace @category Marketplace */ var Marketplace={Entry:{}}; Marketplace.Entry.Offer=Class.extend({_buttons:{},_buttonSelector:"",_dialog:null,_notification:null,_objectID:0,_userID:0,_proxy:null,init:function(a){this._buttonSelector=a;this._buttons={};this._notification=null;this._objectID=0;this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._initButtons()},_initButtons:function(){var a=this;$(this._buttonSelector).each(function(b,d){var c=$(d),e=c.wcfIdentify();a._buttons[e]||(a._buttons[e]=c,c.click($.proxy(a._click,a)))})},_click:function(a){this._objectID= $(a.currentTarget).data("objectID");this._userID=$(a.currentTarget).data("userID");this._proxy.setOption("data",{actionName:"prepareOffer",className:"marketplace\\data\\offer\\OfferAction",parameters:{objectID:this._objectID,userID:this._userID}});this._proxy.sendRequest()},_success:function(a,b,d){a.returnValues.saved?(null===this._notification&&(this._notification=new WCF.System.Notification(WCF.Language.get("marketplace.entry.offer.success"))),this._dialog.wcfDialog("close"),this._notification.show()): a.returnValues.template&&(this._showDialog(a.returnValues.template),a.returnValues.alreadyWarned||this._dialog.find(".jsSubmitWarning").click($.proxy(this._submit,this)))},_showDialog:function(a){null===this._dialog&&(this._dialog=$("#marketplaceOfferDialog"),this._dialog.length||(this._dialog=$('
').hide().appendTo(document.body)));this._dialog.html(a).wcfDialog({title:WCF.Language.get("marketplace.entry.offer")}).wcfDialog("render")},_submit:function(){this._proxy.setOption("data", {actionName:"offer",className:"marketplace\\data\\offer\\OfferAction",parameters:{reason:$("#offerReason").val().trim(),price:$("#offerPrice").val().trim(),objectID:this._objectID,userID:this._userID}});this._proxy.setOption("success",function(a,b,d){window.location.reload()});this._proxy.sendRequest()}}); Marketplace.Entry.OfferDialog=Class.extend({_checkTypeAccept:null,_checkTypeNewOffer:null,init:function(){this._checkTypeAccept=$("#marketplaceOfferTypeAccept");this._checkTypeNewOffer=$("#marketplaceOfferTypeNewOffer");this._checkTypeAccept.change($.proxy(this._changeState,this));this._checkTypeNewOffer.change($.proxy(this._changeState,this))},_changeState:function(){this._checkTypeNewOffer.prop("checked")?($("#marketplaceOfferPrice").show(),$("#marketplaceOfferPrice").find("input").prop("required", "required")):($("#marketplaceOfferPrice").hide(),$("#marketplaceOfferPrice").find("input").prop("required",""))}}); Marketplace.Entry.OfferManagement=Class.extend({_proxy:null,_objectID:0,_entryID:0,_type:"",_notification:null,init:function(){this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});$(".manageOfferButton a").click($.proxy(this._click,this))},_click:function(a){this._objectID=$(a.currentTarget).data("objectID");this._type=$(a.currentTarget).data("type");this._entryID=$(a.currentTarget).data("entryID");this._proxy.setOption("data",{actionName:"manage",className:"marketplace\\data\\offer\\OfferAction", parameters:{objectID:this._objectID,status:this._type}});this._proxy.sendRequest()},_success:function(a,b,d){"accepted"===this._type?window.location.reload():"declined"===this._type&&(a=$(".marketplaceOffer"+this._objectID+" .marketplaceOfferStatusBadge"),a.text(WCF.Language.get("marketplace.entry.offer.status.declined")),a.addClass("red"));$(".marketplaceOffer"+this._objectID+" .manageOfferButton").hide();null===this._notification&&(this._notification=new WCF.System.Notification(WCF.Language.get("marketplace.entry.offer.success."+ this._type)));this._notification.show()}}); Marketplace.Entry.Done=Class.extend({_buttons:{},_buttonSelector:"",_dialog:null,_notification:null,_objectID:0,_userID:0,_proxy:null,init:function(a){this._buttonSelector=a;this._buttons={};this._notification=null;this._objectID=0;this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._initButtons()},_initButtons:function(){var a=this;$(this._buttonSelector).each(function(b,d){var c=$(d),e=c.wcfIdentify();a._buttons[e]||(a._buttons[e]=c,c.click($.proxy(a._click,a)))})},_click:function(a){this._objectID= $(a.currentTarget).data("objectID");this._proxy.setOption("data",{actionName:"prepareUserClosureRequest",className:"marketplace\\data\\entry\\EntryAction",parameters:{objectID:this._objectID}});this._proxy.sendRequest()},_success:function(a,b,d){a.returnValues.saved?(null===this._notification&&(this._notification=new WCF.System.Notification(WCF.Language.get("marketplace.entry.done.success"))),this._dialog.wcfDialog("close"),this._notification.show()):a.returnValues.template&&(this._showDialog(a.returnValues.template), a.returnValues.alreadyWarned||this._dialog.find(".jsSubmitWarning").click($.proxy(this._submit,this)))},_showDialog:function(a){null===this._dialog&&(this._dialog=$("#marketplaceOfferDialog"),this._dialog.length||(this._dialog=$('
').hide().appendTo(document.body)));this._dialog.html(a).wcfDialog({title:WCF.Language.get("marketplace.entry.done.title")}).wcfDialog("render")},_submit:function(){this._proxy.setOption("data",{actionName:"userClosureRequest",className:"marketplace\\data\\entry\\EntryAction", parameters:{username:$("#doneUsername").val().trim(),objectID:this._objectID}});this._proxy.setOption("success",function(a,b,d){window.location.reload()});this._proxy.sendRequest()}}); Marketplace.Entry.Renew=Class.extend({_buttons:{},_buttonSelector:"",_notification:null,_objectID:0,_proxy:null,init:function(a){this._buttonSelector=a;this._buttons={};this._notification=null;this._objectID=0;this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._initButtons()},_initButtons:function(){var a=this;$(this._buttonSelector).each(function(b,d){var c=$(d),e=c.wcfIdentify();a._buttons[e]||(a._buttons[e]=c,c.click($.proxy(a._click,a)))})},_click:function(a){var b=this; WCF.System.Confirmation.show(WCF.Language.get("marketplace.entry.renew.confirm"),function(d){"confirm"==d&&($(b._buttonSelector).hide(),b._objectID=$(a.currentTarget).data("objectID"),b._proxy.setOption("data",{actionName:"renew",className:"marketplace\\data\\entry\\EntryAction",objectIDs:[b._objectID]}),b._proxy.sendRequest())})},_success:function(a,b,d){a.returnValues.saved&&(null===this._notification&&(this._notification=new WCF.System.Notification(WCF.Language.get("marketplace.entry.renew.success"))), this._notification.show(),window.setTimeout(function(){window.location=a.returnValues.url},1E3))}}); Marketplace.Entry.Push=Class.extend({_buttons:{},_buttonSelector:"",_notification:null,_objectID:0,_proxy:null,init:function(a){this._buttonSelector=a;this._buttons={};this._notification=null;this._objectID=0;this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});this._initButtons()},_initButtons:function(){var a=this;$(this._buttonSelector).each(function(b,d){var c=$(d),e=c.wcfIdentify();a._buttons[e]||(a._buttons[e]=c,c.click($.proxy(a._click,a)))})},_click:function(a){$(this._buttonSelector).hide(); this._objectID=$(a.currentTarget).data("objectID");this._proxy.setOption("data",{actionName:"push",className:"marketplace\\data\\entry\\EntryAction",objectIDs:[this._objectID]});this._proxy.sendRequest()},_success:function(a,b,d){a.returnValues.saved&&(null===this._notification&&(this._notification=new WCF.System.Notification(WCF.Language.get("marketplace.entry.push.success"))),this._notification.show())}});Marketplace.Rating={}; Marketplace.Rating.RatingHandler=Class.extend({_selector:null,init:function(a){var b=this;this._selector=a;$(a).each(function(){var a=$(this),c="",e=null,f=a.children();for(i=0;i',$(f[i]).is(":checked")&&(e=$(f[i]).val());f.hide();a.append('
'+c+"
");b._set(a,e);$("a",a).click($.proxy(b._click,b))})},_click:function(a){a.preventDefault();var b=$(a.target);a=b.closest(this._selector); var d=a.children("input"),c=b.closest("a").data("value"),b=d.filter(function(a){$(this).prop("checked",!1);return $(this).val()==c});b.prop("checked",!0);this._set(a,b.val())},_set:function(a,b){b&&a.find(".icon").each(function(){var a=$(this);a.parent().data("value")<=b?a.attr("class","icon icon24 fa-star"):a.attr("class","icon icon24 fa-star-o")})}}); Marketplace.Rating.RatingLoader=Class.extend({_container:null,_ratingType:"seller",_loadButton:null,_noMoreEntries:null,_proxy:null,_userID:0,init:function(a){this._container=$("#marketplaceRatingList");(this._userID=a)?(this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)}),a=$('
  • "+WCF.Language.get("marketplace.rating.noMoreEntries")+ "
  • ").appendTo(this._container),this._loadButton=a.children("button").click($.proxy(this._click,this)),this._noMoreEntries=a.children("small").hide(),3==this._container.find("> li").length&&(this._loadButton.hide(),this._noMoreEntries.show(),this._container.find(".marketplaceRatingSummaryContainer").hide()),$("#marketplaceRatingType .button").click($.proxy(this._clickRatingType,this))):console.debug("[Marketplace.Rating.RatingLoader] Invalid parameter 'userID' given.")},_clickRatingType:function(a){a= $(a.currentTarget);this._ratingType!=a.data("ratingType")&&(this._ratingType=a.data("ratingType"),$("#marketplaceRatingType .button").removeClass("active"),$(".marketplaceRatingSummary").hide(),$("#marketplaceRatingSummary-"+a.data("ratingType")).show(),a.addClass("active"),this._reload())},_reload:function(){this._container.find("> li:not(:first-child):not(:last-child)").remove();this._container.data("lastRatingTime",0);this._click()},_click:function(){this._loadButton.enable();var a={lastRatingTime:this._container.data("lastRatingTime"), userID:this._userID,ratingType:this._ratingType};this._proxy.setOption("data",{actionName:"load",className:"marketplace\\data\\rating\\RatingAction",parameters:a});this._proxy.sendRequest()},_success:function(a,b,d){a.returnValues.template?($(a.returnValues.template).insertBefore(this._loadButton.parent()),this._container.data("lastRatingTime",a.returnValues.lastRatingTime),this._noMoreEntries.hide(),this._loadButton.show().enable()):(this._noMoreEntries.show(),this._loadButton.hide())}}); Marketplace.Rating.Response=Class.extend({_container:null,_proxy:null,init:function(a){this._container=$(a);this._proxy=new WCF.Action.Proxy({success:$.proxy(this._success,this)});$("button",this._container).click($.proxy(this._click,this))},_click:function(a){this._proxy.setOption("data",{actionName:"setResponse",className:"marketplace\\data\\rating\\RatingAction",objectIDs:[this._container.data("ratingID")],parameters:{response:$("textarea",this._container).val()}});this._proxy.sendRequest()},_success:function(a, b,d){a.returnValues.response&&$(".marketplaceRatingResponseText",this._container).html(a.returnValues.response)}});